<template>
  <div>
    <f-table ref="table" rowKey="orderDetailsId" size="small" :showSetting="true" setting-key='sb1'  :tableColumns="columns" :multiple="false" :operator="operator" :scroll="scroll" :params="queryParam" :api="api.payment" handler="customBondReturnPageListHandler">

     <span slot='paymentState' slot-scope='text, record, index'>
            <a-tag color='#87d068' v-if='text==0'>未提交</a-tag>
             <a-tag color='#108ee9' v-if="text==1&&record.taskName=='出纳支付'" @click='processImg(record)'>{{ record.taskName }}</a-tag>
             <a-tag color='#87d068' v-if="text==1&&record.taskName!='出纳支付'" @click='processImg(record)'>{{ record.taskName }}</a-tag>
            <a-tag color='#f50' v-if='text==2' @click='processImg(record)'>已结算</a-tag>
        </span>
      <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.orderInfoDrawer.showDrawer(record)" >查看</a>
            <a-divider type="vertical"/>
            <a @click="startProcess(record)" v-if="record.paymentState==0">提交</a>
          </template>
        </span>
    </f-table>
    <custom-bond-drawer ref="drawer" @success="onLoad"></custom-bond-drawer>
    <order-info-drawer ref="orderInfoDrawer"></order-info-drawer>

  </div>
</template>
<script>
import api from './../js/api'
import CustomBondDrawer from './custombond_drawer'
import OrderInfoDrawer from '../../../business/order/order_info_drawer'

export default {
  name: 'CustomBondYes',
  components: {
    OrderInfoDrawer,
    CustomBondDrawer
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    operator.push({
      name: '添加',
      icon: 'plus',
      that: this,
      handler: function(table, that) {
        that.$refs.drawer.showDrawer()
      }
    })
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      scroll: { x: true },
      // 表头
      columns: [
        {
          title: '#',
          width: '50px',
          align: 'left',
          customRender: (text, record, index) => index + 1
        },
        {
          title: '操作',
          align: 'center',
          width: '150px',
          scopedSlots: { customRender: 'action' }
        },
        {
          title: '单号',
          align: 'left',
          width: '125px',
          dataIndex: 'paymentNo'
        },
        {
          title: '部门',
          align: 'left',
          width: '80px',
          dataIndex: 'deptName'
        },
        {
          title: '业务员',
          align: 'left',
          width: '100px',
          dataIndex: 'saleManName'
        },
        {
          title: '收款金额',
          align: 'left',
          width: '100px',
          dataIndex: 'amount'
        },
        {
          title: '收款日期',
          align: 'left',
          width: '100px',
          dataIndex: 'amountDate'
        },
        {
          title: '制单人',
          align: 'left',
          width: '100px',
          dataIndex: 'nickName'
        },
        {
          title: '审批状态',
          align: 'left',
          width: '130px',
          dataIndex: 'paymentState',
          scopedSlots: { customRender: 'paymentState' }
        },{
          title: '创建日期',
          align: 'left',
          width: '100px',
          dataIndex: 'createTime'
        },
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
      this.$emit('changeTab')
    },
    startProcess(payment) {
      this.http.confirm(this, {
        content: '确认提交审批吗?',
        url: api.processInstance.start,
        requestBody: true,
        data: {
          handlerName: 'customBondStartProcessHandler',
          businessKey: payment.paymentId
        },
        success: function(me, data) {
          me.$refs.table.refresh()
        }
      })
    },
  }
}
</script>
